#include <iostream>
#include<cstring>
#include<algorithm>
using namespace std;

class SeqList {
private:
	int* list;
	int maxsize, size;
public:
	SeqList();
	SeqList(int* data,int n);
	~SeqList();
	int list_size();		//实际长度
	int list_insert(int i,int item);	//插入
	int multi_insert(int i, int n, int item[]);		//连续插入
	int list_del(int i);		//删除
	int multi_del(int i, int n);	//从i开始连续删除n个数据
	int list_get(int i);		//获取
	void list_display();		//打印全表
};

SeqList::SeqList() {		//默认构造
	maxsize = 1000;
	size = 0;
	list = new int[maxsize];
}

SeqList::SeqList(int* data,int n) {
	maxsize = 1000;
	size = n;
	list = new int[maxsize];
	memcpy(list, data, sizeof(data)*n);
}

SeqList::~SeqList()
{
	delete[] list;
}

int SeqList::list_size() {
	return size;
}
int SeqList::list_insert(int i, int item) {
	if (i < 0 || i > size) {
		cout << "error\n";
		return -1;
	}
	//插入，后移
	size++;
	for (int j = size; j > i ; j--) {
		list[j] = list[j-1];
	}
	list[i] = item;
	return 0;
}
int SeqList::multi_insert(int i, int n, int item[]) {
	//连续插入
	if (i < 0 || i > size) {
		cout << "error\n";
		return -1;
	}
	//插入，后移
	size += n;
	for (int j = size; j > i; j--) {
		list[j] = list[j - n];
	}
	int tmp = 0;
	for (int j = i; j < i + n; j++) {
		list[j] = item[tmp];
		tmp++;
	}

	return 0;
}
int SeqList::list_del(int i) {
	if (i < 0 || i > size) {
		cout << "error\n";
		return -1;
	}
	//删除，前移
	for (int j = i; j < size; j++) {
		list[j] = list[j + 1];
	}
	size--;
	return 0;
}

int SeqList::multi_del(int i, int n) {
	//从i开始连续删除n个数据
	if (i < 0 || i > size) {
		cout << "error\n";
		return -1;
	}
	//删除，前移
	for (int j = i; j < i+n; j++) {
		list[j] = list[j + n];
	}
	size-=n;
	return 0;


}	
int SeqList::list_get(int i) {
	if (i < 1 || i >= size) {
		cout << "error\n";
		return -1;
	}
	return list[i];
}
void SeqList::list_display() {
	cout << size << " ";
	for (int i = 0; i < size; i++) {
		cout << list[i]<<" ";
	}
	cout << endl;
}


int main() {
	//int n, index,temp;
	//cin >> n;
	//int* data = new int[n];
	//for (int i = 0; i < n; i++) {
	//	cin >> data[i];
	//}
	//SeqList list(data, n);
	//list.list_display();

	int n1, n2;
	int* data1, *data2;
	//数据输入
	cin >> n1;
	data1 = new int[n1];
	for (int i = 0; i < n1; i++) {
		cin >> data1[i];
	}
	cin >> n2;
	data2 = new int[n2];
	for (int i = 0; i < n2; i++) {
		cin >> data2[i];
	}
	
	//这里偷鸡了一下，没有使用两个顺序表合并而是sort后放到顺序表里
	int n3 = n1 + n2;
	int* data3 = new int[n3];
	memcpy(data3, data1, sizeof(int) * n1);
	memcpy(data3+ n1, data2, sizeof(int) * n2);
	
	//for (int i = 0; i < n3; i++)cout << data3[i] << " ";
	//cout << endl;

	sort(data3, data3 + n3);		//注意sort里未地址在整数时可以不用sizeof,end表示结束地址的下一位

	//for (int i = 0; i < n3; i++)cout << data3[i] << " ";
	//cout << endl;

	SeqList list(data3, n3);
	list.list_display();
}